<style>
    .addBtn{
        text-decoration: none;
        background: #337ab7;
        color: white;
        padding: 5px 10px;
        border-radius: 4px;
        margin-bottom:10px;
        display: inline-block;
    }
    .info-wrap>td {
        text-align: center;
        padding-top: 10px;
    }
    .info-wrap>td>div {
        max-height: 200px;
        overflow-y: auto;
    }
    .tiao-val {
        width: 30px;
        height: 30px;
        margin: 5px 5px 0 0;
        outline: none;
        font-size: 14px;
    }
    .tiao-btn {
        font-size: 14px;
    }
    .link-update{
        text-decoration: none;
        background: #337ab7;
        color: white;
        padding: 5px 10px;
        border-radius: 4px;
        margin-bottom: 10px;
        display: inline-block;
    }
    .link-update:hover{
        text-decoration: none;
        color: white;
        background: #286090;
    }
    .link-del{
        text-decoration: none;
        background: red;
        color: white;
        padding: 5px 10px;
        border-radius: 4px;
        margin-bottom: 10px;
        display: inline-block;
    }
    .link-del:hover{
        text-decoration: none;
        background: red;
        color: white;
    }
    .info-wrap{
        border-bottom: 1px solid #cccccc;
    }
</style>
<div class="span10">
    <div style="margin-bottom: 20px;">
        <a href="/index/index">首页</a><span >&gt;</span><span>广告文案管理</span>
    </div>

    <a class="addBtn" href="<?php echo baseUrl.'/content/ad/add'?>">添加广告文案</a>
    <form action="<?php echo baseUrl ?>/content/ad/index" method="get" class="form-horizontal" style="margin-bottom: 10px;">
        <table class="table">
            <tr>
                <td>
                    选择位置：
                </td>
                <td>
                    <select name="cate" id="cate" >
                        <option value ="">请选择文案图位置</option>
                        <option value ="1" <?php echo isset($_GET) && $_GET!=false && $_GET['cate']==1 ?  'selected':''?>>顶部</option>
                        <option value ="2" <?php echo isset($_GET) && $_GET!=false && $_GET['cate']==2 ?  'selected':''?>>中部</option>
                        <option value ="3" <?php echo isset($_GET) && $_GET!=false && $_GET['cate']==3 ?  'selected':''?>>底部</option>
                    </select>
                </td>
                <td>
                    选择客户端：
                </td>
                <td>
                    <select name="type" id="type" >
                        <option value ="">请选择文案图位置</option>
                        <option value ="1" <?php echo isset($_GET) && $_GET!=false && $_GET['type']==1 ?  'selected':''?>>app</option>
                        <option value ="2" <?php echo isset($_GET) && $_GET!=false && $_GET['type']==2 ?  'selected':''?>>wap</option>
                        <option value ="3" <?php echo isset($_GET) && $_GET!=false && $_GET['type']==3 ?  'selected':''?>>pc</option>
                    </select>
                </td>
                <td>
                    <button class="btn btn-primary" type="submit">提交</button>
                </td>
            </tr>
        </table>
    </form>

    <form action="/content/api/sort" method="post">
        <table border="0" width="100%">
            <tr align="center">
                <th>id</th>
                <th>模块</th>
                <th>名称</th>
                <th>主题</th>
                <th>注释</th>
                <th>时间</th>
                <th width="120px">操作</th>
            </tr>
            <?php
            foreach ($data as $v) {
                ?>
                <tr class="info-wrap">
                    <td>
                        <?php echo $v['id'] ?>
                    </td>
                    <td><?php if($v['cate']==1){echo '顶部';}elseif($v['cate']==2){ echo '中部';}else{echo '底部';} ?></td>
                    <td><?php echo $v['ad_name'] ?></td>
                    <td><?php echo $v['title'] ?></td>
                    <td><?php echo $v['remark'] ?></td>
                    <td><?php echo date('Y-m-d H:i:s',$v['createTime']) ?></td>

                    <td>
                        <a class="link-update"
                           href="<?php echo baseUrl . '/content/ad/add' . '?' . 'id=' . $v['id'] ?>">修改</a>
                        <a class="link-del" href="javascript:;" onclick="del(<?php echo $v['id'] ?>)">删除</a>
                    </td>
                </tr>
            <?php } ?>
        </table>
        <input type="hidden" name="cate" value="4">
        <!-- <button class="push btn btn-primary" type="submit">排序</button> -->
    </form>
</div>
<script>
    function del(id){
        if(confirm("确定删除内容吗")) {
            $.get("/content/ad/del", {id: id},
                function (msg) {
                    if (msg) {
                        alert('删除成功');
                    }
                }, 'text'
            );
        }
    }
</script>
